package com.ruoyi.net.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.net.domain.ElementBusiMplsAlarmoamVo;
import com.ruoyi.net.domain.NetElement;
import com.ruoyi.net.mapper.NetElementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.net.mapper.ElementBusiMplsAlarmoamMapper;
import com.ruoyi.net.domain.ElementBusiMplsAlarmoam;
import com.ruoyi.net.service.IElementBusiMplsAlarmoamService;

/**
 * 网元-业务-mpls-故障检测oamService业务层处理
 * 
 * @author net
 * @date 2024-11-17
 */
@Service
public class ElementBusiMplsAlarmoamServiceImpl implements IElementBusiMplsAlarmoamService 
{
    @Autowired
    private ElementBusiMplsAlarmoamMapper elementBusiMplsAlarmoamMapper;

    @Autowired
    private NetElementMapper elementMapper;

    /**
     * 查询网元-业务-mpls-故障检测oam
     * 
     * @param id 网元-业务-mpls-故障检测oam主键
     * @return 网元-业务-mpls-故障检测oam
     */
    @Override
    public ElementBusiMplsAlarmoam selectElementBusiMplsAlarmoamById(String id)
    {
        return elementBusiMplsAlarmoamMapper.selectElementBusiMplsAlarmoamById(id);
    }

    /**
     * 查询网元-业务-mpls-故障检测oam列表
     * 
     * @param elementBusiMplsAlarmoam 网元-业务-mpls-故障检测oam
     * @return 网元-业务-mpls-故障检测oam
     */
    @Override
    public List<ElementBusiMplsAlarmoamVo> selectElementBusiMplsAlarmoamList(ElementBusiMplsAlarmoam elementBusiMplsAlarmoam)
    {
        List<ElementBusiMplsAlarmoamVo> elementBusiMplsAlarmoams = elementBusiMplsAlarmoamMapper.selectElementBusiMplsAlarmoamList(elementBusiMplsAlarmoam);
        for (ElementBusiMplsAlarmoamVo alarmoam:elementBusiMplsAlarmoams){
            NetElement netElement = elementMapper.selectNetElementById(alarmoam.getElementId());
            if (netElement!=null){
                alarmoam.setElementName(netElement.getElementName());
            }
        }
        return elementBusiMplsAlarmoams;
    }

    /**
     * 新增网元-业务-mpls-故障检测oam
     * 
     * @param elementBusiMplsAlarmoam 网元-业务-mpls-故障检测oam
     * @return 结果
     */
    @Override
    public int insertElementBusiMplsAlarmoam(ElementBusiMplsAlarmoam elementBusiMplsAlarmoam)
    {
        String uuid = IdUtils.simpleUUID();
        if (StringUtils.isEmpty(elementBusiMplsAlarmoam.getId())) {
            elementBusiMplsAlarmoam.setId(uuid);
        }
        elementBusiMplsAlarmoam.setCreateBy(SecurityUtils.getUsername());
        elementBusiMplsAlarmoam.setCreateTime(DateUtils.getNowDate());
        elementBusiMplsAlarmoam.setUpdateBy(SecurityUtils.getUsername());
        elementBusiMplsAlarmoam.setUpdateTime(DateUtils.getNowDate());
        return elementBusiMplsAlarmoamMapper.insertElementBusiMplsAlarmoam(elementBusiMplsAlarmoam);
    }

    /**
     * 修改网元-业务-mpls-故障检测oam
     * 
     * @param elementBusiMplsAlarmoam 网元-业务-mpls-故障检测oam
     * @return 结果
     */
    @Override
    public int updateElementBusiMplsAlarmoam(ElementBusiMplsAlarmoam elementBusiMplsAlarmoam)
    {
        elementBusiMplsAlarmoam.setUpdateBy(SecurityUtils.getUsername());
        elementBusiMplsAlarmoam.setUpdateTime(DateUtils.getNowDate());
        return elementBusiMplsAlarmoamMapper.updateElementBusiMplsAlarmoam(elementBusiMplsAlarmoam);
    }

    /**
     * 批量删除网元-业务-mpls-故障检测oam
     * 
     * @param ids 需要删除的网元-业务-mpls-故障检测oam主键
     * @return 结果
     */
    @Override
    public int deleteElementBusiMplsAlarmoamByIds(String[] ids)
    {
        return elementBusiMplsAlarmoamMapper.deleteElementBusiMplsAlarmoamByIds(ids);
    }

    /**
     * 删除网元-业务-mpls-故障检测oam信息
     * 
     * @param id 网元-业务-mpls-故障检测oam主键
     * @return 结果
     */
    @Override
    public int deleteElementBusiMplsAlarmoamById(String id)
    {
        return elementBusiMplsAlarmoamMapper.deleteElementBusiMplsAlarmoamById(id);
    }
}
